package com.abc.service;

import com.abc.bean.User;
import com.abc.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: bc
 * @Date: 2024-11-17 12:37
 * @Description:
 */
@Service
public class UserService {
    @Autowired
    private UserMapper userMapper;
    public String login(User user){
        User user1 = userMapper.selectUserByUsername(user);
        if(user1!=null && user1.getPassword().equals(user.getPassword())){
            return "登录成功";
        }
        return "用户名或密码错误";
    }
    public String register(User user){
        User user1 = userMapper.selectUserByUsername(user);
        if(user1!=null) {
            return "用户名已存在";
        }
        int i = userMapper.insertUser(user);
        if(i>0){
            return "注册成功";
        }
        return "注册失败";
    }
}
